import logging

from flask import Flask
from flask_migrate import Migrate, MigrateCommand
from flask_script import Manager
from apps.models.news_model import *
from apps.models.user_model import *
from apps import creat_app
from exts import db

app = Flask(__name__)

logger = logging.getLogger(__name__)
logger.setLevel(level = logging.INFO)
handler = logging.FileHandler("log.txt")
handler.setLevel(logging.INFO)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)

app = creat_app()
manager = Manager(app=app)

migrate = Migrate(app=app, db=db)
manager.add_command('db', MigrateCommand)

if __name__ == '__main__':
    manager.run()
